﻿@using S4Store.Domain
@{
    S4Store.Domain.Administrator CurrentUser = (S4Store.Domain.Administrator)ViewBag.CurrentUser;
}
@model S4Store.Models.Zh.ByBrandModel
@{
    Layout = null;
    ViewBag.Title = "ByBrand";

    S4Store.Models.Chart.Line ChartModel = new S4Store.Models.Chart.Line();
    //ChartModel.Name = "登记客户";
    ChartModel.YAxis = "置换率";
    ChartModel.Width = 600;
    ChartModel.Height = 300;
    foreach (var m in Model.ChartReports)
    {
        ChartModel.XAxis.Add(m.Month + "月");
    }
    S4Store.Models.Chart.ChartSeries series1 = new S4Store.Models.Chart.ChartSeries();
    series1.Name = "置换率目标";
    foreach (var m in Model.ChartReports)
    {
        series1.Data.Add(m.CarKpiMonthConfig.InsureTarget);
    }
    ChartModel.Serieses.Add(series1);

    S4Store.Models.Chart.ChartSeries series2 = new S4Store.Models.Chart.ChartSeries();
    series2.Name = "实际置换率";
    foreach (var m in Model.ChartReports)
    {
        series2.Data.Add(m.TBBL);
    }
    ChartModel.Serieses.Add(series2);
    ChartModel.Colors = new List<string> { S4Store.Models.Chart.Color.Green, S4Store.Models.Chart.Color.Blue };
}
<div style="height:100%; overflow:auto">
<div style=" width:100%; height:30px; background:#E5EDEF">
    <div ratio="#25" class="panelBar" style="height: 25px;">
	<ul class="toolBar">
	@if (
                           CurrentUser.Position == S4Store.Domain.Position.SystemManager ||
                           CurrentUser.Position == S4Store.Domain.Position.SaleTutors ||
                           CurrentUser.Position == S4Store.Domain.Position.DealerTutors
                           )
		{
		<li class="historyrecord"><a  backtype="html" href="@Url.Action("AddImproveGuide", "ImproveGuide",  new { guidetype = S4Store.Domain.ImproveGuide.ImproveGuideType.Sale.ToInt() ,referdesc="销售管理>新车置换业绩动态>车型查询"  })" target="dialog" width="60%"><span class="icon edit">填写改善指导建议</span></a></li>
		}
	</ul>
</div>
</div>
<table>
    <tr>
    <td valign="top">
    <div style="margin:10px">@Model.BarModel.Month.ToString("yyyy年M月") KPI数据</div>
    <table  class="reporttable"  style="border-collapse:collapse;">     
<tr  class="vtr">
    <th width="60"  class="inputedheader" rowspan="2">车型</th>
    <th width="105"  class="inputedheader" rowspan="2">车款</th>
    <th   class="inputedheader" colspan="3">本月交车数</th>
    <th   class="inputedheader" colspan="3">
    置换目标: @Model.ZHMB.toInt()% &nbsp;&nbsp;
    目标差异: @Model.ZHCY.toInt()%
    </th>
</tr>
<tr>
    <th class="inputedheader">二网</th>
    <th class="inputedheader">本店</th>
    <th class="inputedheader">总计</th>
    <th class="inputedheader">本月置换数</th>
    <th class="inputedheader">置换比例</th>
    <th class="inputedheader">置换率差</th>
</tr>
@{
    var models = Model.CarKpiPersonBodyModel.GetCarModels(Model.CarBrand);
    int i=0;
    foreach (var carmodel in models)
    {
        var report = Model.CarKpiPersonBodyModel.GetReportByCarModel(carmodel);
        <tr height="26" style="height:19.5pt" class="xl65">
                        @if (i++ == 0)
                        {
                            <td rowspan="@models.Count">@Model.CarBrand.Name</td>
                        }
                        <td>@carmodel.Name</td>
                        <td>@report.BDYJ</td>
                        <td>@report.EWYJ</td>
                        <td>@report.GiveCarCount</td>
                        <td class="calculated">@report.ZHSL</td>
                        <td class="calculated">@report.ZHBL.toInt()%</td>
                        <td class="calculated" @S4Store.Utils.GetBgColor(report.ZHDiff >= 0)>@report.ZHDiff.toInt()%</td>
                    </tr>
    }
}

<tr>
    <th colspan="2">合计</th>
    <td>@Model.BrandReport.BDYJ</td>
    <td>@Model.BrandReport.EWYJ</td>
    <td>@Model.BrandReport.GiveCarCount</td>
    <td class="calculated">@Model.BrandReport.ZHSL</td>
    <td class="calculated">@Model.BrandReport.ZHBL.toInt()%</td>
    <td class="calculated" @S4Store.Utils.GetBgColor(Model.BrandReport.ZHDiff >= 0)>@Model.BrandReport.ZHDiff.toInt()%</td>
</tr>
        </table>
    </td>
    <td valign="top">
    <div style=" width:100%; height:30px; background:#E5EDEF">
    <div style=" padding:5px 10px;width:100%; ">
        <form action="@Url.Action("ByBrand", "zh")">        
            @Html.Partial("YmSeleter", new S4Store.Models.YmList { Start = DateTime.Now.AddYears(-5), End = DateTime.Now, Current = Model.BarModel.Start, Name = "Start" })
            -
            @Html.Partial("YmSeleter", new S4Store.Models.YmList { Start = DateTime.Now.AddYears(-5), End = DateTime.Now, Current = Model.BarModel.End, Name = "End" })
            <input type="hidden" name="SearchCarBrandId" value="@Model.CarBrand.Id" />
          <input type="button" value="查询" class="reportsubmit" />
        </form>
    </div>
</div>
@Html.Partial("../Chart/Line", ChartModel)
    </td>
    </tr>
</table>
        
</div>

